package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo4 {
    public static void main(String[] args) {
        try(
        Connection connection=DBUtil.getConnection();
        ){
            Statement statement = connection.createStatement();
            String sql ="SELECT id,name,salary,teacher,title\n" +
                    "FROM teacher";
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()){
                int id = rs.getInt("id");
                String name = rs.getNString("name");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
